<ul id="topnav">
<?php
$html = array();
$menu = array();
foreach ($this->container as $page) {
    $href = $page->getHref();
    $flag = FALSE;
    if ($page->isActive()){
        $flag = TRUE;        
    } else {
        $pages = $page->getPages();
        foreach ($pages as $item) {
            if ($item->isActive()){
                $flag = TRUE;
            }
        }
    }
    if ($flag == TRUE){
        $html[] = '<li id="active">';
    } else {
        $html[] = '<li>';
    } 
    if ($href) {
        $html[] = '<a href="'. $href . '">';
    } else {
        $html[] = '<a href="#">';
    }
    $html[] = '<i18n>' . $page->getLabel() . '</i18n>';
    $html[] = '</a>';
    $pages = $page->getPages();
    if (null !== $pages) {
        $html[] = '<span style="display:none"><ul>';
        foreach ($pages as $item) {
        if ($item->isActive()){
            $class = 'class="active-sub-menu"';
        } else {
            $class = '';
        }
            $html[] = '<li>';
            $href = $item->getHref();
            if ($href) {
                $html[] = '<a href="'. $href . '"' . $class .'>';
            } else {
                $html[] = '<a href="#">';
            }
            $html[] = '<i18n>' . $item->getLabel() . '</i18n>';
            $html[] = '</a></li>';
        }
        $html[] = '</ul></span>';
    }
    $html[] = '</li>';
    
}
echo implode(PHP_EOL, $html);
?></ul>
<script type="text/javascript">
	$("document").ready(function(){
		 var spanHtml= $("ul#topnav #active span").html();
		 $("ul#topnav #active a").attr('class','active-menu');
		 $("#mainm_inner").html(spanHtml);
	});
    $("ul#topnav li").hover(function() { 
        var spanHtml = $(this).find("span").html();
        $(".active-menu").attr('class','');
		$(this).find('a').attr('class','active-menu');
        $("#mainm_inner").html(spanHtml);
		$("#mainm_inner").hover(
			function() { 
			
			} , 
			function() {
				$(".active-menu").attr('class','');	
			  	var spanHtml= $("ul#topnav #active span").html();
			  	$("ul#topnav #active a").attr('class','active-menu');
			  	$("#mainm_inner").html(spanHtml);
	    	}
		); 
    } , function() { 
    });
</script>  
